package 链表;

import common.ListNode;

/**
 * @author tmh
 * @date 2024/8/18 22:49
 * @description
 */
public class T206反转链表 {
    public ListNode reverseList(ListNode head) {
        if (head == null) {
            return head;
        }
        ListNode pre = null;
        ListNode cur = head;
        while (cur != null) {
            ListNode temp = cur.next;
            cur.next = pre;
            pre = cur;
            cur = temp;
        }
        return pre;
    }

}
